<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>登录</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>

      <style>
        .login{padding: 0 20px;}
        .close{padding: 20px 0 0;}
        .close img{width: 15px;height: 15px;}
        .hello{padding-top: 17.5%;}
        .hello h3{font-size: 20px;color: #000;}
        .hello p{font-size: 13px;color: #999;line-height: 25px}
        .form{padding-top: 80px}
        .form .inpu{width: 100%;padding-bottom: 17px;border-bottom: 1px solid #e5e5e5;margin-bottom: 30px;display: flex;justify-content: space-between;}
        .form .inpu input{font-size: 13px;color: #333;width: 100%;}
        .form .inpu input.code{width: 60%}
        .form .inpu .gain{font-size: 13px;color: #FFAC00;}
        .form .inpu .gary{font-size: 13px;color: #cecece;}
        .comit{width: 100%;display: flex;}
        .comit button{width: 95%;height:50px;background-color: #FBBB3F;margin: 0 auto;border-radius: 30px;color: #fff;font-size: 16px;}
        .explain{text-align: center;font-size: 13px;color: #999;padding-top: 15px}
        .explain .protocol{color: #FFAC00;}
      </style>
  </head>
  <body>
    <div class="login">
      <div class="close"><img src="../image/close.png" ></div>
      <div class="hello">
        <h3>Hello,欢迎来到天天兼职</h3>
        <p>登录后，寻找属于你自己的心仪工作</p>
      </div>
      <div class="form">
        <div class="inpu">
          <input type="number" value=""  maxlength="11" placeholder="请输入手机号" class="iphone"   />
        </div>
        <div class="inpu">
          <input type="number" value=""  placeholder="请输入验证码"  class="code" />
          <span class="gain" id="code" onclick="sendCode()">获取验证码</span>
        </div>
        <div class="comit">
          <button type="button" name="button" onclick="commit()">登录</button>
        </div>
        <div class="explain"><span>点击登录注册即表示您已同意 </span><span class="protocol">用户服务协议</span></div>
      </div>
    </div>
  </body>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/encrypt.js"></script>
  <script type="text/javascript">
      apiready = function(){
        $api.fixStatusBar( $api.dom('.login') );
        $api.addEvt($api.dom('.close'), 'click', function(){
          api.closeWin({
            name: 'login'
          });

        })


      };

      function funcGoto(){

        window.location.reload()
      }

      var base = new Base64();

      var timeClock;
      var num = 1;
      function sendCode() {
          var timer_num = 60;
          if(num == 1){
              num = 0
              var telphone = $api.val($api.dom('.iphone'));
              if(telphone == ''){
                api.toast({
                    msg: '请填写手机号',
                    duration: 2000,
                    location: 'middle'
                });
                return
              }
              var json = {'mobile':telphone}
              var parameter = base.encode(JSON.stringify(json));
              var signValue = parameter + secretKey
              var sign = signValue.MD5(32)

              $api.post(url+'sendLoginVerifyCode.ashx', {values:{parameter:parameter,sign:sign}}, function(ret){

                if(ret.code == 200){

                  timeClock=setInterval(function(){
                    timer_num--;
                    $api.removeCls($api.dom('#code'), 'gain');
                    $api.addCls($api.dom('#code'), 'gary');
                    $api.html($api.dom('#code'), '已发送'+timer_num+'秒');

                    if (timer_num == 0) {
                      clearInterval(timeClock);
                      num = 1
                      $api.removeCls($api.dom('#code'), 'gary');
                      $api.addCls($api.dom('#code'), 'gain');
                      $api.html($api.dom('#code'), '获取验证码');
                    }
                  },1000)
                  api.toast({
                      msg: '发送成功，请注意查收',
                      duration: 2000,
                      location: 'middle'
                  });

                }else{
                  api.toast({
                      msg: ret.msg,
                      duration: 2000,
                      location: 'middle'
                  });
                }
              })
          }

      }


      function commit(){
        var telphone = $api.val($api.dom('.iphone'));
        var code = $api.val($api.dom('.code'));
        if(telphone == ''){

            api.toast({
                msg: '请输入手机号',
                duration: 2000,
                location: 'middle'
            });


          }else if(code == ''){

            api.toast({
                msg: '请输入验证码',
                duration: 2000,
                location: 'middle'
            });
          }else{
            var json = {'mobile':telphone,'code':code}
            var parameter = base.encode(JSON.stringify(json));
            var signValue = parameter + secretKey
            var sign = signValue.MD5(32)
            $api.post(url+'quickLogin.ashx', {values:{parameter:parameter,sign:sign}}, function(ret){
              if(ret.code == 200){

                $api.setStorage('userID', ret.data.userID);
                var jsfun = 'funcGoto()';
                api.execScript({
                  name: 'root',
                  frameName: 'frame3',
                  script: jsfun

                });
                api.closeWin();

              }else{

                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'middle'
                });

              }
            });

          }
      }

  </script>
  </html>
